home *** CD-ROM | disk | FTP | other *** search
/ TeX 1995 July / TeX CD-ROM July 1995 (Disc 1)(Walnut Creek)(1995).ISO / web / fweb / fweb-1.40 / manual / demo0.web < prev    next >
Text File  |  1993-10-29  |  3KB  |  70 lines

  1. @z --- demo0.web ---
  2.  
  3. This file is part of FWEB.  It and its tangled output demo0.tex are
  4. included into the user manual fwebman.tex.  All web source files should
  5. have header information such as this.
  6.  
  7. Author:  J. A. Krommes
  8. Version: 1.23
  9. Date:    April 1, 1992
  10.  
  11. @x-----------------------------------------------------------------------------
  12.  
  13. @c @% This command (invisible on output) sets the global language to C.
  14. @* EXAMPLE. The `\.{@@*}'~begins a major module or section (one for which an
  15. entry is made in the table of contents). We are now in the \TeX\ part of
  16. the section, in which we can type arbitrary \TeX\ to explain what goes on in
  17. the remainder of the section.
  18.  
  19. The next statement introduces the definition part of this section.
  20. \modlabel{FirstMod} % Attach an identifying name to this section.
  21.  
  22. @m PRINT(word) printf("%s, world.\n",#word) /* An example of a \.{WEB}
  23.     macro def'n.  They are compatible with ANSI~C, but have extensions
  24.     (not illustrated here) that will be explained later.
  25.     Long comments that extend over more than one line can be written
  26.     like this, in the C commenting style. */ 
  27.  
  28. @a @% The @a command (invisible on output) introduces the code part of
  29.    @% this (unnamed) module.
  30. main()
  31. {
  32. PRINT(Hello); /* Bullets as subscripts indicate that the name is defined in
  33.     the current section. */
  34. init(); /* Example of a function call.  The subscript is inserted
  35.     automatically, and indicates in which section the function is
  36.     defined. */
  37. @<Do the computations@>; /* Use of named modules makes the code readable.
  38.     Again, the section number where this module is defined is inserted
  39.     automatically. */
  40. PRINT(Goodbye);
  41. }
  42.  
  43. @ The `\.{@@\ }'~begins a minor section.  (No entry is made in the table of
  44. contents.)  Here the named fragment |@<Do...@>| used in the previous module
  45. is actually defined.  (The definition part of this section is empty.) The
  46. name of this module is `Do the computations'; it can be abbreviated (using
  47. an ellipsis) for simplicity in the source because it appeared earlier in
  48. full; however, when it's printed the full name will be used for
  49. readability.
  50.  
  51. @<Do the comp...@>=
  52. {
  53. /* Put arbitrary C code here. */
  54. }
  55.  
  56. @ In general, function names don't carry as much information as do named
  57. modules, since a module name can be arbitrarily long and complicated.  But
  58. function calls have their place as well, as described later.
  59.  
  60. This function is actually accreted to the unnamed module begun in
  61. \WEBsection{FirstMod}.  Examine the source listing to see how the section
  62. number in the last sentence was generated automatically through the use of
  63. \FWEB's \TeX\ macros \.{\\modlabel} and \.{\\WEBsection}.
  64.  
  65. @a 
  66. void init(void)
  67. {}
  68.  
  69. @* INDEX.  It's customary to make the index the last major module.
  70.